//
//  FP_UserPriceInquiryInfoCell.m
//  FootPad
//
//  Created by 张浩 on 2022/2/17.
//  Copyright © 2022 胶享悦. All rights reserved.
//

#import "MM_HomeSkuDdetailGiveawayListCell.h"

static const CGFloat addTitleTag = 2000;

@interface MM_HomeSkuDdetailGiveawayListCell ()

@property (nonatomic, strong) UIView *baseView;

@end

@implementation MM_HomeSkuDdetailGiveawayListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [ColorUtil colorWithHexadecimal:@"#ffffff"];
        [self.contentView addSubview:_baseView];
        
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.left.right.top.bottom.equalTo(self.contentView);
            make.height.equalTo(70);
        }];
        
    }
    return self;
}

- (void)setModel:(MM_HomeSkuDdetailGiveawayModel *)model {
    _model = model;
    
    NSArray *titleArr = @[!stringIsEmpty(model.spu_name)?model.spu_name:@"",!stringIsEmpty(model.sku_name)?model.sku_name:@"",!stringIsEmpty(model.sku_code)?model.sku_code:@"",!stringIsEmpty(model.count)?model.count:@""];
//    NSArray *titleWArr = @[@(9),@(6),@(5),@(5)];
    CGFloat titleW = ScreenW /titleArr.count;
//    CGFloat titleX = 0;
        
    for (UIView*subView in self.baseView.subviews) {
        
        [subView removeFromSuperview];
    }
    
    for (int i=0; i<titleArr.count; i++) {
        
        UIView *titleView = [[UIView alloc] init];
        titleView.backgroundColor = [ColorUtil colorWithHexadecimal:@"#ffffff"];
        titleView.tag = addTitleTag + i;
//        titleView.layer.borderColor = MM_ColorUtil(@"#eeeeee").CGColor;
//        titleView.layer.borderWidth = 0.5;
        [self.baseView addSubview:titleView];
        
        [titleView mas_makeConstraints:^(MASConstraintMaker *make) {
           
            make.left.equalTo(i * titleW);
            make.top.height.equalTo(self.baseView);
            make.width.equalTo(titleW);
        }];
                
        UILabel *nameLabel = [Custom_ZHTool uiLabelCreate:titleArr[i] Font:FONT(12) TextColor:[ColorUtil colorWithHexadecimal:@"#333333"]];
        nameLabel.numberOfLines = 0;
        nameLabel.textColor = [ColorUtil colorWithHexadecimal:@"#333333"];
        
        [titleView addSubview:nameLabel];
        
        [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            
               if (i == 0 || i== 1) {
                make.left.equalTo(12);
                make.right.equalTo(-5);
                make.centerX.equalTo(titleView);
            }else {
                make.centerX.equalTo(titleView);
            }
            make.centerY.equalTo(titleView);
        }];
                
        UIView *lineView_2 = [[UIView alloc] init];
        lineView_2.backgroundColor = [ColorUtil colorWithHexadecimal:@"#DDDDDD"];
        [titleView addSubview:lineView_2];
         
        [lineView_2 mas_makeConstraints:^(MASConstraintMaker *make) {

            make.left.bottom.equalTo(titleView);
//            make.top.equalTo(self.scrollView);
            make.width.equalTo(titleW);
            make.height.equalTo(0.5);
        }];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end
